home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1996-01-17 | 4.4 KB | 126 lines |
- ' ************************************* Commands used:
- ' * * Ham Fade =Glue Colour
- ' * Amcaf Examples * =Ham Colour Turbo Point
- ' * Ham Commands V1.0 * =Ham Best Turbo Plot
- ' * Written by Chris Hodges * =Red Val =Mix Colour
- ' * * =Green Val
- ' ************************************* =Blue Val
- '
- ' Let's load a ham-picture.
- Load Iff "Data/AMCAFHam.iff",0
- ' So... I want to recolour it.
- ' To keep the program compatible with other screen sizes, I copy the
- ' dimensions into the variables WX and WY.
- WX=Screen Width
- WY=Screen Height
- ' We need two loops to readout every dot on the screen.
- ' Because I think you are quite impatient, I only change the upper quater.
- For Y=0 To WY/4-1
- ' As this is the beginning of a new horizontal line, I must reset some
- ' variables. HAM1 holds the composite colour information of the old original
- ' screen datas in the format $RGB.
- ' And so HAM1 must be set to Colour(0).
- HAM1= Colour(0) : HAM2=HAM1
- For X=0 To WX-1
- ' The next instruction reads the pixel from the coords x,y.
- P= Extension_8_039E(X,Y)
- ' Now let's calculate the effect of this pixel. Therefore I must give
- ' the composite colour of the pixel before.
- HAM1= Extension_8_09E8(P,HAM1)
- ' Split the new value into the three components
- RED= Extension_8_03B2(HAM1)
- GREEN= Extension_8_03C0(HAM1)
- BLUE= Extension_8_03D0(HAM1)
- ' Now let's modify some values:
- ' Add 4 to the RED value, but keep track of the maximum.
- RED=Min(RED+4,15)
- ' Invert all GREEN shapes.
- GREEN=15-GREEN
- ' And at last sub 2 from the BLUE value.
- BLUE=Max(BLUE-2,0)
- ' Build the new composite colour
- NEW= Extension_8_0A0E(RED,GREEN,BLUE)
- ' Now I must search the best colour for changing the picture.
- ' To do this, I call =Ham Best with the old colour, and the
- ' colour, I want to have as result.
- P= Extension_8_09FC(NEW,HAM2)
- ' Rewrite the pixel
- Extension_8_0388 X,Y,P
- ' Calculate the real effect of that modification.
- HAM2= Extension_8_09E8(P,HAM2)
- Next
- Next
- ' Now I want to blend out this ham-pic.
- ' So Ham Fade Out is used.
- ' Every time it's been called, the screen gets one darker. After 16 calls
- ' the screen is completely black.
- For A=0 To 15
- ' Synchronise with the raster beam.
- Wait Vbl
- ' And fade...
- Extension_8_0FBA 0
- Next
- Screen Close 0
- ' Close the screen nicely :)
- '
- ' There are so many other possibilities about what you can do with the ham
- ' commands, but I only will take one out: Mixing two normal pictures into
- ' one ham screen.
- ' Load a new 32 colours picture.
- Load Iff "Data/Weazle.iff",0 : Screen Hide
- ' Get the dimensions of the screen.
- WX1=Screen Width
- WY1=Screen Height
- ' Load the second one and get width and height.
- Load Iff "Data/Beach.iff",1 : Screen Hide
- WX2=Screen Width
- WY2=Screen Height
- ' Calculate the size of the new screen. Therefore the mininum value of both
- ' is taken.
- WX=Min(WX1,WX2)
- WY=Min(WY1,WY2)
- ' Now open the third screen. Note that this one is HAM.
- Screen Open 2,WX,WY,4096,Lowres
- Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 0
- ' Then the palettes should be mixed to get better results, but it is NOT
- ' neccessary at all!
- ' First I copy the whole palette from screen 0.
- Get Palette 0
- ' In a loop I take each colour and mix it using the Mix Colour function.
- For A=0 To 31
- Screen 1
- C1= Colour(A)
- Screen 2
- C2= Colour(A)
- Colour A, Extension_8_0EE8(C1,C2)
- Next
- ' Now comes the main part. It's quite similar to the upper part.
- For Y=0 To WY-1
- ' At the beginning of a line, set the old colour to the border colour,
- ' that is Colour(0).
- HAM= Colour(0)
- For X=0 To WX-1
- ' Get pixel x,y of screen 0.
- Screen 0
- P1= Extension_8_039E(X,Y)
- ' Get the composite colour.
- C1= Colour(P1)
- ' Get pixel x,y of screen 1 and composite colour.
- Screen 1
- P2= Extension_8_039E(X,Y)
- C2= Colour(P2)
- ' Mix these colours.
- NEW= Extension_8_0EE8(C1,C2)
- ' Don't forget to change to the ham screen, as Ham Best gets the palette
- ' from the current screen, and that must be the ham screen.
- Screen 2
- ' Now calculate the best ham colour. As always, we need the colour of the
- ' previous pixel.
- P= Extension_8_09FC(NEW,HAM)
- ' Write the new pixel to the screen
- Extension_8_0388 X,Y,P
- ' And at last, calculate the real colour change.
- HAM= Extension_8_09E8(P,HAM)
- Next
- Next
- End